package collision;

import java.util.Enumeration;

import javax.media.j3d.Behavior;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.WakeupOnCollisionEntry;
import javax.media.j3d.WakeupOnCollisionExit;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;

public class NavigationCollision extends Behavior{

	private TransformGroup target = null;
	private TransformGroup camTG = null;
	private TransformGroup canonTG = null;
	private BoundingSphere bound = null;
	
	public NavigationCollision(TransformGroup target, 
			TransformGroup camTG, TransformGroup canonTG) {
		this.setSchedulingBounds(new BoundingSphere());
		this.target = target;
		this.target.setCapability(TransformGroup.ENABLE_COLLISION_REPORTING);
		this.bound = new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), 32.0d);
		this.camTG = camTG;
		this.canonTG = canonTG;
	}
	
	@Override
	public void initialize() {
		// TODO Auto-generated method stub
		this.wakeupOn(new WakeupOnCollisionExit(this.bound));
//		this.wakeupOn(new WakeupOnCollisionExit(this.target));
//		this.wakeupOn(new WakeupOnCollisionEntry(this.target));
//		this.wakeupOn(new WakeupOnCollisionMovement(this.target));
	}

	@Override
	public void processStimulus(Enumeration arg0) {
		// TODO Auto-generated method stub
		Transform3D backToCenterCam = new Transform3D();
		Transform3D backToCenterCanon = new Transform3D();
		backToCenterCam.setTranslation(new Vector3f(0.0f, 0.0f, 10.0f));
		backToCenterCanon.setTranslation(new Vector3f(0.0f, -1.0f, 7.0f));
		this.camTG.setTransform(backToCenterCam);
		this.canonTG.setTransform(backToCenterCanon);
		System.out.println("Kollision mit Nav...");
		this.wakeupOn(new WakeupOnCollisionExit(this.bound));
//		this.wakeupOn(new WakeupOnCollisionExit(this.target));
//		this.wakeupOn(new WakeupOnCollisionEntry(this.target));
//		this.wakeupOn(new WakeupOnCollisionMovement(this.target));
	}

}
